#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <iterator>
#include <functional>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/timer.hpp>
#include <boost/shared_ptr.hpp>

using namespace std;
typedef map<string,int> SIM;

struct AddMap{
        SIM* mp;
	AddMap(SIM* mpp):mp(mpp){}
	void operator()(string s){
		++(*mp)[s];
	}
};

int main(int argc, char** argv){
	if( argc==1 ){
		cout<<"cmd file"<<endl;
		exit(1);
	}

	map<string,int> words;
	ifstream file(argv[1]);
	istream_iterator<string> in(file),endf;
	for_each(in,endf,AddMap(&words));

//	cout<<words.size()<<endl;
        pair<string,int> p;
        BOOST_FOREACH( p, words){
   	     cout<<p.first<<"  "<<p.second<<endl;
	}

	return 0;
}
